Copyright: Copyright ©1997-1998 Cripton Corp


Overview of Object Pascal Script

Object Pascal Script is a scripting language based on the Inprise implementation of Pascal.  The primary differences between Pascal and Object Pascal are the use of objects, to provide an Object Oriented framework around which to develop applications.

Whilst providing some objects, Web Development Kit's implementation of Object Pascal in it's scripting language, is a heavily reduced language.  WDK provides most of the important features of Object Pascal you will need, while remaining true to the Object Pascal development language.

Pascal was written to teach people to program, and so it is one of the easiest languages to learn.  By looking at examples from WDK, and in fact examples of programs written in Object Pascal, you can learn to use the language well.

Web Development Kit provides users with the ability to script their web pages, making it easier to reuse the same HTML in many places where small deviations may be necessary.  Previously this was only possible by duplicating code.


Using Object Pascal Script

To use OPScript™ in your page development, you need to use a special tag.  The OPScript tag looks like <+ +>.  In between these two tags you enter your script.  Delphi users will be familiar with the following protocols.

When starting your script, you must always begin with a begin statement.  All scripts must end with an end; statement (see example 1.1).

<+

begin

  // my script will go here

end;

+>

Example 1.1

While the remaining examples in this help file do not include the <+ +> tags, you are always required to use them when writing scripts in WDK.

If you wish to create more complex scripts, you can use functions and procedures which you define above your primary begin..end block (see example 1.2).  It is also possible to declare block global variables before your begin..end block.

procedure ShowMyName(MyName: String);

begin

  ShowMessage(MyName);

end;

begin

  ShowMyName;

end;

Example 1.2

The power of OPScript gives you the best possible control over the elements in your web pages.


TStrings

 Properties          [image] Methods

TStrings is an abstract class for objects used to represent a list of strings.

Description

Derive a class from TStrings to store and manipulate a list of strings. Descendants of TStrings can represent several individual strings, such as the individual lines that appear in a list box. Some objects use descendants of TStrings to represent one long body of text so that it can be manipulated in smaller chunks.

TStrings introduces many properties and methods to

•	Add or delete strings at specified positions in the list.

•	Rearrange the strings in the list.

•	Access the string at a particular location.

•	Read the strings from or write the strings to a file or stream.

•	Associate an object with each string in the list.


TStrings Properties

 Commatext

 Count

 Strings

 Names

 Objects

 Text

 Values


StrToInt Function

function StrToInt(const S: string): Integer;

The StrToInt function converts a string representing an integer-type number in either decimal or hexadecimal notation into a number. If the string does not represent a valid number, StrToInt raises an EConvertError exception.

Example

This example converts the string '22467' into an integer, increments that value, then reconverts that new value back to an a string so that it can be displayed in a message dialog:

var

  S: string;

  I: Integer;

begin

  S := '22467';

  I := StrToInt(S);

  I := I+1;

  ShowMessage(IntToStr(I));

end;


AnsiCompareStr Function

function AnsiCompareStr(const S1, S2: string): Integer;

AnsiCompareStr compares S1 to S2, with case sensitivity. The compare operation is controlled by the current Windows locale.

The return value is:

Condition	Return Value

S1 > S2	> 0

S1 < S2	< 0

S1 = S2	= 0


AnsiCompareText Function

function AnsiCompareText(const S1, S2: string): Integer;

AnsiCompareText compares S1 to S2, without case sensitivity. The compare operation is controlled by the current Windows locale. CompareStr returns a value less than 0 if S1 < S2, a value greater than 0 if S1 > S2, and returns 0 if S1 = S2.


AnsiLowerCase Function

function AnsiLowerCase(const S: string): String;

AnsiLowerCase converts all characters in the given string to lower case. The conversion uses the current Windows locale. This function supports double-byte character sets (DBCS).


AnsiUpperCase Function

function AnsiUpperCase(const S: string): String;

AnsiLowerCase converts all characters in the given string to upper case. The conversion uses the current Windows locale. This function supports double-byte character sets (DBCS).


Val Procedure

procedure Val(S; var V; var Code: Integer);

 The Val function converts the string value S to its numeric representation, as if it were read from a text file with Read.

S is a string-type expression; it must be a sequence of characters that form a signed whole number. V is an integer-type or real-type variable. Code is a variable of type Integer.

If the string is invalid, the index of the offending character is stored in Code; otherwise, Code is set to zero. For a null-terminated string, the error position returned in Code is one larger than the actual zero-based index of the character in error.

Example

var
  I, Code: Integer;
begin
  Val('blah', I, Code);
  { Error during conversion to integer? }
  if code <> 0 then
  begin
    WriteLn('Error at position: ' + IntToStr(Code));
  end
  else
    WriteLn('Value = ' + IntToStr(I));
end;


VarArrayOf Function

function VarArrayOf(const Values: array of Variant): Variant;

The VarArrayOf function returns a one-dimensional variant array with the elements given by the Values parameter. The low bound of the returned array is zero, the high bound is the number of values given by the Values parameter less one, and the element type is Variant.


VarArrayDimCount Function

function VarArrayDimCount(const A: Variant): Integer;

The VarArrayDimCount function returns the number of dimensions of the given variant. The resulting value is zero if the given variant is not a variant array.


VarArrayLowBound Function

function VarArrayLowBound(const A: Variant; Dim: Integer): Integer;

The VarArrayLowBound function returns the low bound of the given dimension in the given variant array. The Dim parameter should be 1 for the leftmost dimension, 2 for the second leftmost dimension, and so on. An EVariantError exception is raised if the variant given by A is not an array, or if the dimension specified by Dim does not exist.


VarArrayHighBound Function

function VarArrayHightBound(const A: Variant; Dim: Integer): Integer;

The VarArrayHighBound function returns the high bound of the given dimension in the given variant array. The Dim parameter should be 1 for the leftmost dimension, 2 for the second leftmost dimension, and so on. An EVariantError exception is raised if the variant given by A is not an array, or if the dimension specified by Dim does not exist.


VarArrayRef Function

function VarArrayRef(const A: Variant): Variant;

Use this function to reference a variant array when a referenced variant array is expected in some API call.


VarAsType Function

function VarAsType(const V: Variant; VarType: Integer): Variant;

The VarAsType function converts the variant given by V to the type given by VarType. The resulting value is a variant of the type given by VarType. The VarType parameter must be one of the TVarData type codes, and cannot include the varArray or varByRef bits. An EVariantError exception is raised if the variant cannot be converted to the given type.

The VarCast procedure provides the same functionality as VarAsType.


VarClear Procedure

procedure VarClear(var V: Variant);

After the call to VarClear, the variant, V, has the value Unassigned. V can be either a Variant or an OleVariant, but it must be an lvalue.


VarCopy Procedure

procedure VarCopy(var Dest: Variant; const Source: Variant);

The VarCopy procedure copies the variant given by Source into the variant given by Dest. The call VarCopy(Dest, Source) is the same as writing Dest := Source. Dest can be a Variant or an OleVariant, and it must be an lvalue. Source is defined as a Variant, but an OleVariant should be silently allowed because it is a compatible type. The following table lists the expected behavior when using Variant and OleVariant types as parameters:

Dest 	          Source	Behavior

Variant	OleVariant	Fine as is.

Variant	Variant	Fine as is.

OleVariant	OleVariant	Fine as is.

OleVariant	Variant	Source should be implicitly cast to an OleVariant.


VarFromDateTime Function

function VarFromDateTime(DateTime: TDateTime): Variant;

The VarFromDateTime function returns a variant that contains the given date and time value. The type code of the resulting variant is varDate.


VarIsArray Function

function VarIsArray(const V: Variant): Boolean;

The VarIsArray function returns True if the given variant is an array. Otherwise, the function result is False.


VarIsEmpty Function

function VarIsEmpty(const V: Variant): Boolean;

The VarIsEmpty function returns True if the given variant contains the value Unassigned. If the variant contains any other value, the function result is False.


VarIsNull Function

function VarIsNull(const V: Variant): Boolean;

The VarIsNull function returns True if the given variant contains the value Null. If the variant contains any other value, the function result is False.


VarToDateTime Function

function VarToDateTime(const V: Variant): TDateTime);

The VarToDateTime function converts the given variant to a date and time value. An EVariantError exception is raised if the conversion fails.


VarToStr Function

function VarToStr(const V: Variant): string;

The VarToStr function converts the data in a variant to a string.


VarType Function

function VarType(const V: Variant): Integer;

The VarType function returns the type code of the given variant.


Overview of Web Development Kit

Web Development Kit™ provides a set of tools to cut your development time down, and to increase overall productivity.  By using options such as scripting, variables, databases, and external application execution, you have no limits to what you can do with WDK.

WDK™ can be extended using Plugins.  Plugins are written by programmers and put into your <%WDKRoot%>\plugins directory.  Once you restart WDK, you have extra functionality.  Anyone can write a plugin with a little programming knowledge.  Visit http://wdk.cripton.com for more information.

WDK uses project management to keep your web sites together.  Once you create a project, you can start using scripting, includes and all of the other extended features of WDK.  Even if you are working on a very small site, you should use projects.


Registering Web Development Kit

Registering WDK is required if you intend to use it beyond the 30 day trial period.  Prices vary depending on the type you purchase.

WDK Lite costs $117.00 US Dollars

WDK Pro costs $149.00 US Dollars

NOTE: prices are correct at the time of release, but may change.  Prices are Per user.

Registration removes the 30-day trial limit, and removes the floating advert which is put onto each page built with the WDK demonstration version.  In addition, registration gives you free minor upgrades, and E. Mail support.

If you have access to the Internet, you can register online via Secure Server.  For more information visit our web site: http://wdk.cripton.com

For information on the differences between the lite, and pro versions of WDK see the Product Comparison section.


Prduct Comparison

Product Comparison

The demonstration version of WDK is a 30-day trial version of WDK Lite.  This page will help you decide whether you need all the features of the Pro version, or whether you only need WDK Lite.

WDK Pro includes additional scripting function to provide access to Databases using SQL queries, and standard access.

WDK Pro also includes an extra tag <db> which is used to build a table from the queried contents of a database.


Contacting Cripton Corp.

We can be contacted on the internet or via regular mail.  Please use the most convenient method listed below.

Internet

http://www.cripton.com or

http://www.us.cripton.com

info@cripton.com

support@cripton.com

webmaster@cripton.com

bugs@cripton.com

wish@cripton.com

Regular Mail

Oceania - Headquarters

Cripton Corp.
281 Naenae Road
Hutt City, 6009
New Zealand

USA

Cripton Corp.
11 broadway suite 1030
New York
New York 10004
U.S.A.

Canada

Cripton Corp.
1519 8th Ave
New Westminster, BC
Canada
V3M 2S5


Copy Function

function Copy(S: string; Index, Count: Integer): string;

The Copy function returns a substring of a string.

S is a string-type expression. Index and Count are integer-type expressions. Copy returns a string containing Count characters starting at S[Index].

If Index is larger than the length of S, Copy returns an empty string.

If Count specifies more characters than are available, the only the characters from S[Index] to the end of S are returned.

Example

var S: string;

begin

  S := 'ABCDEF';

  S := Copy(S, 2, 3);	{ 'BCD' }

end;


Date Function

function Date: TDateTime;

The Date function returns the current date.

Example

begin

 WriteLn('Today is  ' + DateToStr(Date));

end;


DateToStr Function

function DateToStr(Date: TDateTime): string;

The conversion uses the format specified by the ShortDateFormat global variable.

Example

begin

 WriteLn('Today is  ' + DateToStr(Date));

end;


DecodeDate Function

DecodeDate Procedure

procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);

The DecodeDate procedure breaks the value specified as the Date parameter into Year, Month, and Day values. If the given TDateTime value is less than or equal to zero, the year, month, and day return parameters are all set to zero.

Example

var

  Present: TDateTime;

  Year, Month, Day: Word;

begin

  Present:= Now;

  DecodeDate(Present, Year, Month, Day);

  WriteLn('Today is Day ' + IntToStr(Day) + ' of Month '

    + IntToStr(Month) + ' of Year ' + IntToStr(Year));

end;


Delete Procedure

procedure Delete(var S: string; Index, Count:Integer);

Removes a substring of Count characters from string S starting with S[Index].

S is a string-type variable. Index and Count are integer-type expressions.

If Index is larger than the length of S, no characters are deleted. If Count specifies more characters than remain starting at the S[Index], Delete removes the rest of the string.

Example

var
  s: string;
begin
   s := 'Honest Abe Lincoln';
   Delete(s,8,4);
   WriteLn(s);	{ 'Honest Lincoln' }
end;


EncodeDate Function

function EncodeDate(Year, Month, Day: Word): TDateTime;

The EncodeDate function returns a TDateTime type from the values specified as the Year, Month, and Day parameters.

The year must be between 1 and 9999.

Valid Month values are 1 through 12.

Valid Day values are 1 through 28, 29, 30, or 31, depending on the Month value. For example, the possible Day values for month 2 (February) are 1 through 28 or 1 through 29, depending on whether or not the Year value specifies a leap year.

If the specified values are not within range, an EConvertError exception is raised. The resulting value is one plus the number of days between 12/30/1899 and the given date.

Example

var
  MyDate: TDateTime;
begin
  MyDate := EncodeDate(83, 12, 31);
  WriteLn(DateToStr(MyDate));
end;


FloatToStr Function

function FloatToStr(Value: Extended): string;

FloatToStr converts the floating-point value given by Value to its string representation. The conversion uses general number format with 15 significant digits.


Format Function

function Format(const Format: string; const Args: array of const): string;

This function formats the series of arguments in the open array Args. Formatting is controlled by the Object Pascal format string Format; the results are returned in the function result as a Pascal string.


FormatDateTime Function

function FormatDateTime(const Format: string; DateTime: TDateTime): string;

FormatDateTime formats the date-and-time value given by DateTime using the format given by Format. The following format specifiers are supported:

c	Displays the date using the format given by the ShortDateFormat global    variable, followed by the time using the format given by the LongTimeFormat global variable. The time is not displayed if the fractional part of the DateTime value is zero.

d	Displays the day as a number without a leading zero (1-31).

dd	Displays the day as a number with a leading zero (01-31).

ddd	Displays the day as an abbreviation (Sun-Sat) using the strings given by the ShortDayNames global variable.

dddd	Displays the day as a full name (Sunday-Saturday) using the strings given by the LongDayNames global variable.

ddddd	Displays the date using the format given by the ShortDateFormat global variable.

dddddd	Displays the date using the format given by the LongDateFormat global variable.

m	Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mm	Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mmm	Displays the month as an abbreviation (Jan-Dec) using the strings given by the ShortMonthNames global variable.

mmmm	Displays the month as a full name (January-December) using the strings given by the LongMonthNames global variable.

yy	Displays the year as a two-digit number (00-99).

yyyy	Displays the year as a four-digit number (0000-9999).

h	Displays the hour without a leading zero (0-23).

hh	Displays the hour with a leading zero (00-23).

n	Displays the minute without a leading zero (0-59).

nn	Displays the minute with a leading zero (00-59).

s	Displays the second without a leading zero (0-59).

ss	Displays the second with a leading zero (00-59).

t	Displays the time using the format given by the ShortTimeFormat global variable.

tt	Displays the time using the format given by the LongTimeFormat global variable.

am/pm	Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.

a/p	Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.

ampm	Uses the 12-hour clock for the preceding h or hh specifier, and displays the contents of the TimeAMString global variable for any hour before noon, and the contents of the TimePMString global variable for any hour after noon.

/	Displays the date separator character given by the DateSeparator global variable.

:	Displays the time separator character given by the TimeSeparator global variable.

'xx'/"xx"	Characters enclosed in single or double quotes are displayed as-is, and do not affect formatting.

Format specifiers may be written in upper case as well as in lower case letters—both produce the same result

If the string given by the Format parameter is empty, the date and time value is formatted as if a 'c' format specifier had been given.

Example:

begin
  WriteLn(FormatDateTime('"The meeting is on" dddd, mmmm d, yyyy, '+
  '"at" hh:mm AM/PM', Now));
end;


FormatFloat Function

function FormatFloat(const Format: string; Value: Extended): string;

FormatFloat formats the floating-point value given by Value using the format string given by Format.


FPower10 Function

function FPower10(Val: Extended; Pow: Integer ) : Extended;

FPower10 returns Val * 10**Pow. It is more efficient to call FPower10 than to perform the same computation explicitly.


WDK Projects

Web Development Kit™ uses project files to organize your web site.  Project files contain variables, and HTML source documents (.hts).

It is recommended that you use Projects for all your sites because of the major reduction in time.

To create a new project, click the File Menu and select New Project.  This will open the New Project wizard.  You will be asked to specify the following:

Project Name: This is the name you wish to give your project- it can be anything

Image Prefix: This is the text you want to put in front of any images you embed using the image include tag <&&>.  An example might be imgsrc/ which would result in your images displaying:

<img src=”imgsrc/MYIMAGE.GIF” border=0>

Source Directory:  This is the folder on your computer that you wish to keep your project file, and all HTML source documents associated with it in.

Output Directory:  This is the directory you wish to have your files output to when you compile them (Project | Build All)

Image Directory:  This is the directory you wish to keep your web sites images in.  When looking for Images included with the <&&> tag, WDK will look in this directory first (unless you specify the full path to your images).

Once you have entered all of this information, click finish and WDK will generate your project file.  Once you open your project you can start adding HTML Source documents to it using Project | Add to project.

NOTE: All of the special functions which WDK provides, such as Object Pascal script, file includes etc, are only available when working with projects.

You can change your projects option at any time by opening it and selecting Options from the Project Menu.


HTML Source Files

HTML Source files are text documents which contain an optional mixture of HTML, Object Pascal Scripting, File Includes, Variables, Databases and External Applications.

HTML Source files are compiled by WDK when you select Build All from the project menu, or click the Build All toolbar button.

To create a new HTML Source file, select New from the File menu, or click the New button.  This will open a new document which you can edit.  In order for WDK to process your page, you should save it with the .hts file extension (default) and add it to your project by selecting Add to Project from the Project menu.

Once you have edited your document, save it and click Build All.  WDK will then generate your resulting web pages and put them into your projects Output directory.


Variables

Variables provide you with the ability to make aliases from your most often repeated text.  For example, if you find yourself constantly writing the same Font tag over and over, you can simply make a variable to hold your font tags value, and then use the shorter variable in your HTML Source files.

To create a new variable, click Organize Variables from the Project Menu (you must have a project open).  A dialog box appears and displays any variables you have already set, or allows you to add new ones.

The name field is the short name you wish to give your variable, and the value is the text you wish to output when WDK builds your project.

To use a variable you simply type its name between <% %> tags.  If you define a variable for <font face=”arial” size=-1> called def_font, you would type:

<%def_font%> into your HTML source document.  When you save and build your file, <%def_font%> will be replaced with <font face=”arial” size=-1>.

In addition to customized variables, WDK also offers some default system variables:

System Variables:

Header – Embeds a single line of commented text into your document providing information about it.  For example: <!-- WDK1.0::PROJECTFILENAME::COMPILE TIME::COMPILE DATE -->

SourceDir – Inserts your Projects Source Directory

OutputDir – Inserts your Projects output directory

ImageDir – Inserts your Projects image directory

ImgPrefix – Inserts your projects Image Prefix

TimeNow – Inserts the current time

DateNow – Inserts the current date

Projectpath – Inserts the full path to your project file

WDKRootDir – Inserts the full path to wdk.exe

SystemDir – Inserts your computers system directory

WinDir – Inserts your computers Windows directory

BuildNum – Inserts the build number of wdk.exe

ProjFile – Inserts the name of your project (including extension)

SnippetsDir – Inserts the full path to the WDK Snippets directory (including final \)

System variables are used in the same way as custom variables.

If you want to see the value of a variable at design time, hold the mouse over your variable in the editor window.

NOTE: Variables are case sensitive.  This means that def_font is not the same as Def_Font or dEf_font.


Includes (HTML Snippets)

Includes allow you to embed text from other files.  This is especially useful when you have text too long to use in a variable, or text which spans more than 1 line.

To embed an HTML Snippet you put the name of the snippet (if it resides in your source directory or the WDK snippets directory) or the full path and name of the snippet between <& &> tags.

For example, to embed the full contents of the file MyCode.hsn (.hsn is the default HTML snippets extension) you would type the following into your current document:

<&MyCode.hsn&>

When you build your page or project, WDK will try to find that file first in the projects source directory, and second in the snippets directory.  The following is also acceptable:

<&c:\mywebsite\extras\myfile.hsn&>

Using this method you can embed .ops files (Object Pascal Script), .html files, .txt files etc.

NOTE:  You can use all of the extended features of WDK in variables and snippets, or as the result of a database include.  WDK recursively compiles, meaning that variables in includes will be processed, or includes in variables ad infinitum.

You should note however, that it is not a good idea to embed an include within itself, as this will cause an eternal loop and you will need to use brute force to terminate WDK, loosing any changes you have made to your document.

It is very important to ensure that you always close include tags properly with &> as this will ensure no looping.

If you wish to have an include which is independent of the current project, simply place it in the snippets directory under the main WDK directory.  You can then use this in any project by entering its name between <& &> tags.


External Applications

The <* *> tag allows you to execute external applications and have the results embedded in your document.  This is especially useful if you need to do something which OPScript will not allow, but Perl will.

NOTE: You should not use the <* *> tag with standard windows applications.  You should only use it with dos or WindowsNT console applications (these are programs which run in a black screen instead of in a gray window).

An example of using the <* *> tag:

<*c:\perl5\perl.exe MyScript.pl*>


Defines

You can use Defines to do basic search/replace functionality at build time.  Defines allow you to easily keep different environments for different builds.

Defines use a $DEFINE tag.  Example:

{$DEFINE type=”body” value=”<body bgcolor=Navy>”}

When you build your page, the above define will replace all instances of the word body with the words <body bgcolor=Navy>

Another example of its use is to provide designtime versus runtime paths.  Example:

{$DEFINE type=”c:\windows\” value=”/windows/”}

You can set up a large series of defines in an HTML snippet file (.hsn) which you can imbed on all pages of your site in an include.  Example:

<&Definitions.hsn&>

If you wish to undefine a define, but don’t wish to permanently remove it, simply put a . in front of the $ character.  Example:

{.$DEFINE type=”test” value=”Made with WDK”}


Scripts

WDK comes with native support for Object Pascal scripting.  For more information on using OPScript with WDK please see the Object Pascal Reference in this help file.

Object Pascal Scripts use the <+ +> tag.

An example of using OPScript in your document follows.  This example will display a small window when you build your project.

<+

begin

  ShowMessage(‘This is my text Object Pascal Script’);

end;

+>


Databases

The <db> tag is used to embed information from databases into your current document.*  Additionally you can use Object Pascal script to access databases.  This topic deals specifically with the <db> tag.  For more information on using databases from Object Pascal Scripts, see the Object Pascal Reference.

* Pro version only


How It All Works

WDK uses a special technology not available in any other web development product.  This technology allows you to build static web pages from dynamic information.

This means that you no longer need to use buggy JavaScript’s to write Last Updated information on your WebPages.  You no longer need to worry about trying to find an Internet Provider that will let you host a database.  You no longer need to worry about making changes to every page of your 500 page web site!

By using includes, scripting, databases, and more, you simply design your pages, and compile them into static pages.  If you decide to change the default font of your web site – no problem, just change a variable, rebuild- and your whole site is updated!

WDK does not provide the ability to use dynamic pages on the internet.  WDK generates only static pages – but it generates those pages from dynamic information hosted on your computer or network.


New

The New menu item opens the Object Repository.  This gives you a series of choices regarding the document type you wish to open.

Any documents to add to the repository from the “Add to Object Repository” popup menu in the editor, are available here on the User tab.


New Project

Clicking the New Project menu item opens the New Project Wizard which guides you through creating a new project.


Open

The Open menu item opens the standard Windows Opendialog which you can use to open a project, image or document.


Open From the Web

The Open From the Web menu items allows you to open web pages directly from a web site for editing.  You enter the full URL for the web page, or image, and the directory you wish to save the file in.  Once the file is downloaded WDK opens it.


Recent Projects

When you open a project file (.wdk) it gets added to the Recent Projects menu.  You can then select your project from this menu to open it in future.


Reopen File

All documents you open with WDK are added to the Reopen File menu.  You can select any of these files to reopen them with WDK.


Save

When you click this menu item, the current document is saved.  If the document does not already exist on your computer, you are prompted with the Save As dialog so you can choose a name to save the file as.


Save As

The Save As menu item allows you to save a document under a new name, or to save a document which you haven’t saved before.


Save Project

The Save Project menu item saves your current project.


Save Project As

The Save Project As menu item saves your current project to a different file name.


Save All

The Save All menu item saves all currently open documents which have been modified, and any open modified projects.


Close

The Close menu item closes the currently open editor.  If the documents contents have been modified you are prompted to save your changes.


Close Project

The Close Project menu item saves the current project if it has been modified.  To save it under a different filename, use Save As on the File menu.


Close All

The Close All menu item closes all currently open projects, documents and images.  If any of the documents or projects have been modified, you are prompted to save them.


Printer Setup

The Printer Setup menu item opens the standard windows Printer Setup dialog which can be used to modify printer settings such as paper size, print orientation etc.  Changes made here are system wide.


Print

The Print menu item will print the document in the active editor window.  To change the print options use the Printer Setup option on the File menu.


Exit

The Exit menu item closes Web Development Kit.  If you have any modified documents or projects open, you will be prompted to save them.


Undo

Selecting the Undo menu item will remove the last modification you made to the current editor.  You can use Control-Z as a shortcut key for Undo.


Redo

Selecting the Redo menu item will re-enter the change last made with by Undo menu item.


Cut

The Cut menu item copies the currently selected text in the editor to the windows clipboard, and deletes the selected text.  You can use Control-X to cut the selected text, and Control-V or Shift-Ins to paste it into another document.  If you accidentally cut text, use Control-Z or the Undo menu item or button to restore the cut text.


Copy

The Copy menu item copies the currently selected text in the editor to the windows clipboard.  Unlike the Cut menu item, Copy will not delete the currently selected text.  You can use Control-C to copy the selected text, and Control-V or Shift-Ins to paste it into another document.


Paste

The Paste menu places the contents of the Windows Clipboard into the current editor.  You can use Shift-Ins or Control-V as a shortcut key for this command.


Delete

The Delete menu item removes the currently selected text from the editor.  If you accidentally delete text, you can use Control-Z or the undo menu item or button to restore the text.


Select All

The Select All menu item selects all of the text in the current editor.  This is especially useful if you have a very large document and want to copy it to the Windows clipboard for pasting into another document, or if you want to delete the entire contents of the current editor.


Indent Selected Text

The Indent Selected Text menu item moves all of the selected text in the current editor to the right by a customizable number of spaces.  To customize the number of spaces, select Editor Options from the View menu


Unindent Selected Text

The unindent Selected Text menu item moves all of the selected text in the current editor to the left by a customizable number of spaces.  To customize the number of spaces, select Editor Options from the View menu


Change Case

The Change Case menu item allows you to modify the case of the currently selected text.  You can modify the text in 4 ways:

1: Lower Case

this is some text

2: Upper Case

THIS IS SOME TEXT

3: Toggle Case

tHIS iS sOME tEXT

4: Title Case

This Is Some Text


Find

The Find menu item prompts you for a word to find in the current editor.  If the editor finds the word, it is highlighted.  After finding your word, you can hit F3 to find the next instance, or you can select Show All from the search menu to have all instances of the word selected.

If you have Regular Expressions checked on the Search menu you can use standard regular expression matching.  See the Regular Expressions help topic for more information on Regular Expressions.


Find Next

The Find Next menu item searches the current editor from the last found instance of the word you are searching for, for other instances of the same word.  You can use F3 as a shortcut for this menu item.


Replace

The Replace menu item prompts you for a word to find, and text to replace it with.  You can choose to replace all instances of the words found, or to replace them one by one – prompted before each change.


Regular Expressions

The Regular Expressions menu item toggles Regular Expression checking in search and replace functions on and off.

Regular expressions can be used to specify text by its characteristics rather than by the exact characters.

For example:

("http://"|"mailto:"|"ftp://")[^ \n\r\"\<\\]+

Would allow the detection of internet references that start with 'http://', 'mailto:' or 'ftp://'. The <field values> will be assigned based upon the syntax element <factor> and devolve to:

        %1.....("http://"|"mailto:"|"ftp://")

        %2.....[^ \n\r\"\<\\]+

In english, the expression reads:

"Find all occurrences of text that start with 'http://', 'mailto:' or 'ftp://' and are followed by at least one character that is not one of a space (\s), a newline(\n), a carriage return(\r), a quote(\"), a bracket (\<), or a slash (\\)"


Show All

The Show All menu item selects all words in the current editor which match the word you last searched for using the Find menu item.


Go To Line

The Go To Line menu item prompts you for a line number.  When you click OK, the cursor in the current editor is moved to the number you specified when prompted.


Toolbars

The Toolbars submenu items can be used to hide and show the various Web Development Kit Toolbars.


Menu Animation

The Menu Animation submenu items can be used to change the style of the Main Menu animation, or to turn animation off.


WDK Bar

The WDK Bar menu item can be used to show and hide the WDK Bar (the panel on the left side of the main window containing the file list and color picker).


Preferences

The Preferences menu item is used to configure all of the various options in WDK.


Editor Options

The Editor Options menu item is used to configure Syntax Highlighting, Code Insight, Auto-Correct and general editor preferences.


Data Types and Variables

 WDK has the ability for your script to use variables for holding values of data. These variables can be any one of six basic types:

•	Integer - Integer variables hold whole numbers in the range –32768..32767

•	LongInt - LongInt variables hold whole numbers in the range -2147483648..2147483647

•	Real - Real variables hold real numbers in the range

•	String – String variables hold text strings, like file names, or machine names. Literal strings in WDK are surrounded by single quotes.

•	Char – Char variables hold a single character. Literal characters in WDK are surrounded by single quotes.

•	Boolean – Boolean values hold one of two values, true or false.

As mentioned before, variables are used to hold data values. To declare a variable for use in your script, use the following syntax:

var VarName: VarType;

The reserved word ‘var’ need only be used once in any variable block declaration. Multiple variables of the same type can be declared together, with a comma separating the names. Variable names are composed of combinations of uppercase and lowercase letters. Here are some sample variable declarations in WDK:

var X, Y, Z: Integer;
    Name, Address: String;
    Income: Real;
    Status: Char;


Assignment Statements

Variables in WDK are assigned values with assignment statements. Assignment statements take the following form:

VarName:=Expression;

Where ‘Expression’ is a valid value or mathematical expression. Here are some examples, in a sample script:

var MyInt: Integer;
    MyStr: String;
    MyBoolean: Boolean;
    MyReal: Real;
    MyChar: Char;
    MyLongInt: LongInt;

begin
  MyInt:=5;
  MyStr:='WDK scripting is great!';
  MyBoolean:=True;
  MyReal:=4.756 + 2.345;
  MyChar:='A';
  MyLongInt:=MyInt*5;   // Would yield 5*5 or 25 as the value
end;

A variable can also be assigned the return value of a WDK function. For example (using the variables from above):

MyStr:=InputBox('Getting user name','Please enter your name','');

places the return value of the InputBox function (a string) into the MyStr variable. See the section on functions for a fuller explanation of function return values.


Data Conversion Functions

IntToStr

function IntToStr(IntValue:Integer): String;

The IntToStr function is used to convert an integer value to a string value.

var MyStr: String;
    MyInt: Integer;

begin
  MyInt:=5;
  MyStr:=IntToStr(MyInt);
  MyStr:=IntToStr(3);
end;

StrToInt

function StrToInt(StrValue:String): Integer;

The StrToInt function is used to convert a string value to an integer value.

var MyStr: String;
    MyInt: Integer;

begin
  MyInt:=StrToInt('1234');
  MyStr:='556';
  MyInt:=StrToInt(MyStr);
end;

* Note – a string value as the argument to this function that is not a valid integer will yield an error.

FloatToStr

function FloatToStr(RealValue:Real): String;

The FloatToStr function is used to convert a real value to a string value.

var MyReal: Real;

begin
  MyReal:=123.456;
  ShowMessage(FloatToStr(MyReal));
end;

StrToFloat

function StrToFloat(StrValue:String): Real;

The StrToFloat function is used to convert a string value to a real value.

var MyString: String;

begin
  MyString:='123.456';
  MyReal:=StrToFloat(MyString);
  MyReal:=StrToFloat('54.56');
end;

* Note - a string value as the argument to this function that is not a valid real will yield an error.


String Functions

Length

function Length(StrValue:String): Integer;

The length function returns the length, in characters, of the given string.

var MyInt: Integer;

begin
  MyInt:=Length('WDK scripting');
end;

Pos

function Pos(SubStr, StrValue:String): Integer;

The Pos function returns the position of the string SubStr in the string StrValue. The position is returned as an integer representing the offset from the beginning of StrValue where SubStr is located.

var MyPos: Integer;

begin
  MyPos:=Pos('erm','WDK');
  // MyPos is 4, because 'erm' starts at position 4 in 'WDK'
end;

Copy

function Copy(StrValue:String; Start,Count:Integer): String;

The Copy function copies Count characters from the Start position in StrValue. The function returns the copied substring as a result.

var MyStr: String;

begin
  MyStr:=Copy('Web Development Kit Pro',3,4);
end;

Insert

procedure Insert(Str1:String; var Str2:String; Index:Integer);

The Insert procedure inserts Str1 into Str2 at position Index.

var Str: String;

begin
  Str:='WDK scripting';
  Insert('does ',Str,12);
  // Str is now 'WDK does scripting'
end;

Delete

procedure Delete(var Str:String; Start,Count:Integer);

The Delete procedure deletes Count characters from Str starting at position Start.

var Str: String;

begin
  Str:='WDK does scripting';
  Delete(Str,12,5);
  // Str is now 'WDK scripting'
end;


Loop Controls

The for loop

for LoopVar:=StartVal to|downto EndVal do statement;

The for loop counts from StartVal to EndVal by 1, executing statement each time. LoopVar, StartVal, and EndVal are all integers or longints. To count backwards, use downto. If statement needs to be a block of statements, surround the block with begin..end;

var X: Integer;
    Str: String;

begin
  for X:=1 to 5 do
    ShowMessage(IntToStr(X));
  Str:='';
  for X:=5 downto 1 do
  begin
    Str:=Str+IntToStr(X);
    ShowMessage(Str);
  end;
  // Str is now '54321'
end;

The while loop

while condition do statement;

The while loop executes statement as long as condition is true. If statement needs to be a block of statements, surround the block with begin..end;

var X, Y: Integer;

begin
  X:=1;
  Y:=0;
  while X<100 do
  begin
    Y:=Y+X;
    X:=X+1;
  end;
  ShowMessage(IntToStr(Y));
  // Y is the sum of all the numbers from 1 to 100
end;

The repeat loop

repeat statement until condition;

The repeat loop repeats statement until condition is true. statement can be a block of statements without the necessity of a begin..end.

var X, Y: Integer;

begin
  X:=1;
  Y:=0;
  repeat
    Y:=Y+X;
    X:=X+1;
  until X=101;
  // Y is the sum of the integers from 1 to 100
end;


Functions and Procedures

Writing procedures and functions

WDK scripting provides them means for you to write your own procedures and functions for your scripts, because sometimes scripts get too long and cumbersome to have everything in one big begin..end block. The following rules apply when writing procedures and functions:

•	Procedure and function names can be any combination of upper and lower case letters

•	All procedures and functions must be defined above the main begin..end block of the script.

•	Variables declared inside a procedure or function are local to that procedure or function only. They are not known outside the procedure or function.

•	Procedures and functions can use global variables from the script, as long as the procedures and functions come after the global variable declarations.

•	Any time you want to modify the value of a parameter to a procedure or function, you must use the reserved word ‘var’ in front of the variable declaration in the parameter list.

Procedures

procedure ProcName[(parameter list)];

[ var section ]

begin

end;

As an example, let’s revisit the script from the help on the if statement, this time rewritten to use a procedure.

var Age: Integer;
    AgeStr: String;
    IsValid: Boolean;

procedure IsValidInt(Str:String; var IsValid:Boolean);
var Loop: Integer;
    AgeChar: Char;
begin
  IsValid:=True;
  if (Str='') then Result:=False
  else
    for Loop:=1 to Length(AgeStr) do
    begin
      AgeChar:=Copy(AgeStr,Loop,1);
      // Check to make sure each char is a valid number
      if (AgeChar<'0') or (AgeChar>'9') then
        IsValid:=False;
    end;
end;

begin
  repeat
    AgeStr:=InputBox('Getting age','Please enter your age','');
    IsValidInt(AgeStr,IsValid);
    if (not IsValid) then
      ShowMessage('Sorry, '+AgeStr+
                  ' is not a valid number. Please try again.');
  until (IsValid) or (AgeStr='');
  if (AgeStr='') then AgeStr:=0;
  Age:=StrToInt(AgeStr);
  if (Age<21) then ShowMessage('Still a kid.')
  else if (Age<40) then ShowMessage('Wet behind the ears')
  else if (Age<65) then ShowMessage('Middle aged')
  else ShowMessage('Would you like a 10% discount?');
end;

Functions

function FuncName[(parameter list)]: ResultType;

[var section]

begin

end;

Functions are like procedures, except they can have a return value. The type of the return value is spceified by the ResultType. To set the return value for a function, use Result. Let’s revisit the script from the help on the if statement, this time rewritten with functions.

var Age: Integer;
    AgeStr: String;
    IsValid: Boolean;

function IsValidInt(Str:String): Boolean;
var Loop: Integer;
    AgeChar: Char;
begin
  Result:=True;
  if (Str='') then Result:=False
  else
    for Loop:=1 to Length(AgeStr) do
    begin
      AgeChar:=Copy(AgeStr,Loop,1);
      // Check to make sure each char is a valid number
      if (AgeChar<'0') or (AgeChar>'9') then
        Result:=False;
    end;
end;

begin
  repeat
    AgeStr:=InputBox('Getting age','Please enter your age','');
    IsValid:=IsValidInt(AgeStr);
    if (not IsValid) then
      ShowMessage('Sorry, '+AgeStr+
                  ' is not a valid number. Please try again.');
  until (IsValid) or (AgeStr='');
  if (AgeStr='') then AgeStr:=0;
  Age:=StrToInt(AgeStr);
  if (Age<21) then ShowMessage('Still a kid.')
  else if (Age<40) then ShowMessage('Wet behind the ears')
  else if (Age<65) then ShowMessage('Middle aged')
  else ShowMessage('Would you like a 10% discount?');
end;


Conditional Statements

The if statement

if condition then statement1

[ else statement2 ];

The if statement is used to test one or more conditions and perform statement1 if that/those conditions are true. If you are testing multiple conditions, each condition must be in a set of parentheses, and the conditions must be separated by reserved words and or or.

If you use the optional else, then statement2 is performed if condition is false. Additionally, if you use an else, statement1 must not have a semi-colon at the end.

Valid comparison operators for conditions are:

•	= - equal to

•	< - less than

•	> - greater than

•	<> - not equal to

•	<= - less than or equal to

•	>= - greater than or equal to

•	not – for Boolean types only. (not true) = false, and (not false) = true

var Age, Loop: Integer;
    AgeStr: String;
    IsValid: Boolean;
    AgeChar: Char;

begin
  IsValid:=False;
  while (not IsValid) do // Make sure they enter a valid number
  begin
    AgeStr:=InputBox('Getting age','Please enter your age','');
     IsValid:=True;
    for Loop:=1 to Length(AgeStr) do
    begin
      AgeChar:=Copy(AgeStr,Loop,1);
      // Check to make sure each char is a valid number
      if (AgeChar<'0') or (AgeChar>'9') then
        IsValid:=False;
    end;
    if (not IsValid) then
      ShowMessage('Sorry, '+AgeStr+
                  ' is not a valid number. Please try again.');
  end;
  Age:=StrToInt(AgeStr);
  if (Age<21) then ShowMessage('Still a kid.')
  else if (Age<40) then ShowMessage('Wet behind the ears')
  else if (Age<65) then ShowMessage('Middle aged')
  else ShowMessage('Would you like a 10% discount?');
end;


Build All

The Build All menu item processes all files in the currently open project, generating .html files from your .hts (HTML source) files.  It is at this point that all scripts, includes, variables, etc. are processed.


Add File

The Add File menu allows you to add new .hts files to your current project.  This menu item is enabled if you have a project open.  The file you add will be compiled next time you do a Build All.


Remove File

The Remove File menu item allows you to remove the selected file (selected in the File List) from the open Project.  Once the file is removed it will not be processed next time you compile.


Preview

The Preview menu item opens the currently selected (selected in the file list) document in your default web browser.  When you select this option, the page you are previewing is first compiled so you can see the final result.


Organize Variables

The Organize Variables menu item lets you configure the variables for your current project.  For more information on variables click here


Options

The options menu item lets you configure the preferences for your current project, including source directory, output directory, and more.


InsertImageEx Procedure

procedure insertimageEx(ImageName, Alt, Extras, Imgpref: String; Border: Integer);

The InsertImageEx procedure is an extension of InsertImage.  With InsertImageEx you can define the options for the entire image tag.  The only things that are automatically inserted, and cannot be overridden are the image height/width properties.

This procedure works for jpeg and gif images.

Example 1

This example inserts the image named balloon.gif in the projects images directory.

begin

  insertimageEx('balloon.gif', 'My Balloon', '', '', 1);

end;

This will result in the following tag:

<img src="balloon.gif" height=10 width=20 border=1 alt="My Balloon">

Example 2

This example inserts the image named balloon.gif in the c:\ directory.

begin

  insertimageEx('c:\balloon.gif', 'My Balloon', 'OnMouseOver="balloon();"', '', 0);

end;

This will result in the following tag:

<img src="balloon.gif" height=10 width=20 border=0 OnMouseOver="balloon();" alt="My Balloon">


InsertImage Procedure

procedure insertimage (ImageName, Alt, Extras: String);

The InsertImage procedure is used to insert an image into the current document.

This procedure works for jpeg and gif images.

This procedure automatically adds your projects ImagePrefix.

Example 1

This example inserts the image named balloon.gif in the projects images directory.

begin

  insertimage('balloon.gif', 'My Balloon', '');

end;

This will result in the following tag:

<img src="ImgPref/balloon.gif" height=10 width=20 alt="My Balloon">

Example 2

This example inserts the image named balloon.gif in the c:\ directory.

begin

  insertimage('balloon.gif', 'My Balloon', 'OnMouseOver="balloon();"');

end;

This will result in the following tag:

<img src="ImgPref/balloon.gif" height=10 width=20 alt="My Balloon" OnMouseOver="balloon();">


WriteLn Procedure

procedure WriteLn(Text: String);

The WriteLn procedure inserts text into the current document at Build Time.

Example

begin

  WriteLn('This is a test');

end;

The above example will insert the text "This is a test" into the output document.


CurFile Function

function CurFile: String;

The CurFile function returns the full name of the document currently being built.  I.e, the name of the document the function is used in.

Example

begin

  WriteLn('You are reading: '+CurFile);

end;

If the document is called c:\windows\test.hts the output document will read:

You are reading c:\windows\test.hts


CreateDB Function

function CreateDB(Alias, DBName: String): Boolean;

The CreateDB function is used to prepare a Database Object for processing of the DB contents.

This function can access a database on a network drive and is only available in WDK Pro.

Example

begin

  CreateDB('CD_COL','cd_data.db');

end;

The above example will open the database named CD_COL and will prepare itself to access the contents in cd_data.db.

If you are using a database format which doesn’t use aliases, simply pass '' for the alias parameter, and put the full path to the database file in the second parameter.

NOTE:  Anytime you call CreateDB, you should call FreeDB when you are done with it to ensure that all memory associated with the database is freed.


FreeDB Function

function FreeDB: Boolean;

The FreeDB function frees any memory being used by the currently open Database.  You should always call this function after you have finished working with a database you have opened with the CreateDB function.

You can check the return value to see if the call succeeded or not.

This function is available only in the Pro version of WDK.


DBGetVal Function

function DBGetVal(FieldName: String): String;

The DBGetVal function is used to get the list of values stored in the specified Field.  For example, if you have a field named Author, you would do DBGetVal('Author');

The result of this call contains a comma delimited list of the values of the specified field.  See the Sample Scripts section for an example of splitting a comma delimited string into a StringList.

This function is available only in the Pro version of WDK.

Example

Var

  MyString: String;

begin

 MyString := DBGetVal('Address1');

end;


CreateSQL Procedure

procedure CreateSQL;

The CreateSQL function is used to prepare a new SQL Object for database access.

You should always make a call to FreeSQL when you have finished working with the SQL Object.

This function is available only in the Pro version of WDK.


FreeSQL Procedure

procedure FreeSQL;

The FreeSQL function is used to free any memory used by the current SQL Object.

You should always make a call to FreeSQL when you have finished working with an SQL Object created with the CreateSQL procedure.

This function is available only in the Pro version of WDK.


SQLSetSQL Procedure

function SQLSetSQL;

The FreeSQL function is used to free any memory used by the current SQL Object.

You should always make a call to FreeSQL when you have finished working with an SQL Object created with the CreateSQL procedure.

This function is available only in the Pro version of WDK.


SQLSetDBName Function

function SQLSetDBName(DBName: String): Boolean;

This function sets the name of the Database you have created with the CreateSQL procedure.

The DBName property is the name of the Database Alias.  This function is only required if you are using a database format which uses aliases.

This function is available only in the Pro version of WDK.


SQLSetState Function

function SQLSetState(State: Boolean): Boolean;

This function activates your SQL Query and runs the query against the database.  When the state has been set true, you can query the results using the SQLGetResults function.

This function is available only in the Pro version of WDK.


SQLGetResults Function

function SQLGetResults(FieldName: String): String;

This function returns a comma delimted string containing all the values held in the specified FieldName property.  You can use a script to split the comma delimited text into a string list (see the Sample Scripts Section).

This function is available only in the Pro version of WDK.


GetVar Function

function GetVar(VarName: String): String;

The GetVar function can be used to retrieve the value of a system or user specified variable.  The result of the function is the value of the variable specified by VarName.

This function goes hand in hand with the SetVar function which is used to set variables at build time.


DefVar Function

function DefVar(VarName, VarValue: String): Integer;

The DefVar function is used to create new variables at build time.  This function is especially useful if you wish to set information at the start of a build which you will use on all following pages.

Variables created with this function last until the current build is completed.  They are not accessible from within the IDE and are not stored between builds.

This function goes hand in hand with the GetVar function which is used to get variable values at build time.


ForceDirectories Procedure

procedure ForceDirectories(DirectoryName: String);

The ForceDirectories function creates a directory.  If the directory is a subdirectory, and its parent directory does not exist, it will create the parent.

This differs from the CreateDir function primarily in its creation of all levels of the specified directory.


CreateDir Procedure

procedure CreateDir(DirectoryName: String);

The CreateDir procedure creates the directory specified in the DirectoryName parameter.  If the directories parents do not exist, the call fails.  If you wish to create a directory and to ensure that its parent directories exist, you should use the ForceDirectories procedure.


ExtractFileName Function

function ExtractFileName(FileName: String): String;

The ExtractFileName function extracts the filename from a full file path specified in the FileName parameter and returns the result.

Example:

ExtractFileName('c:\windows\autoexec.bat');

The above code will return the text "autoexec.bat" without the quotation marks.


ExtractFilePath Function

function ExtractFilePath(FileName: String): String;

The ExtractFilePath function extracts the path from a full file path and name specified in the FileName parameter and returns the result.

Example:

ExtractFilePath('c:\windows\autoexec.bat');

The above code will return the text "c:\windows\" without the quotation marks.


StripFileExt Function

function StripFileExt(FileName: String): String;

The StripFileExt function extracts the filename minus the extension from string in the  FileName parameter and returns the result.

Example:

StripFileExt('autoexec.bat');

The above code will return the text "autoexec " without the quotation marks.


ChangeFileExt Function

function ChangeFileExt(FileName, Extension: String): String;

The ChangeFileExt function changes the file extension of the filename specified in the FileName parameter and returns the result.

Example:

ChangeFileExt('c:\windows\autoexec.bat', '.txt');

The above code will return the text "c:\windows\autoexec.txt" without the quotation marks.

NOTE:  If you wish to remove the file extension simply specify '' as the second parameter.

Example:

ChangeFileExt('autoexec.bat', '');

The above code returns "autoexec" without the quotation marks.


Ord Function

function Ord(Character: String): Integer;

The Ord function returns the ascii number equivalent of the specified character.

Example:

WriteLn('<p>MyName &'+Ord('™')+';</p>';

The above example inserts "<p>MyName &1753;</p>" into the current document without the quotation marks.


ScanF Function

function ScanF(Text, SearchString: String, StartPos: Integer): Integer;

The ScanF function is used to scan text for a search string.  If the search string is found, the resulting position in the string is returned.  If you wish to use case insensitive searching specify -1 as the start position, otherwise specify 1.

Example:

ScanF('My Name Is Bob', 'is', -1);

The above code will result in a return value of 9 because the word "is" starts at position 9 in the string.


BuildFile Procedure

procedure BuildFile(FileName: String);

The BuildFile procedure adds the specified file to the build queue.  This can be used to add files created dynamically from a string list to the build queue, making possible the creation of an entire web site from a single .hts file.

The file must exist, and you are responsible for deleting the file once you have finished with it.  To delete the file you can add the file to the Delete Queue with the DelQueue procedure.


DelQueue Procedure

procedure DelQueue(FileName: String);

The DelQueue procedure adds the specified filename to the list of files to be deleted once the current build has been completed.  This is especially useful if you create a lot of files dynamically and add them to the build queue with the BuildFile function.


DeleteFile Procedure

DeleteFile Function

procedure DeleteFile(FileName: String): Boolean;

The DeleteFile function is used to delete the specified FileName.  If the return value is True, the file was deleted successfully, otherwise the file was not deleted.


Last Updated Sample Script

This example script inserts the Last Updated date into your current file.

Example:

begin

  WriteLn('Last Updated: '+DateToStr(Now)+'<br>');

end;


Comma Delimited String Sample Script

Comma Delimited Strings Sample Script

This example script splits a comma delimited string into a set of strings stored in a stringlist.

Example:

Procedure SplitCommaText(Text: String; ResultList: TStringList);

var

  TheWord, CommaText: String;

begin

  CommaText := Text;

  while (Pos(',', CommaText) > 0) do

  begin

    TheWord := Copy(CommaText, 1, Pos(',', CommaText) - 1);

    CommaText := Copy(CommaText, Pos(',', CommaText) + 1, Length(CommaText));

    ResultList.Add(TheWord);

end;

To use this function create a string list and pass your comma delimited text and the string list to the function.  After the call you can access the items in the string list.

Example:

var

  TheList: TstringList;

  TheText: String;

begin

  TheList := TstringList.Create;

  TheText := 'one, two, three, four';

  SplitCommaText(TheText, TheList);

  For I := 0 to TheList.count-1 do

  begin

    ShowMessage(TheList.Strings[I]);

  end;

  TheList.Free;

end;